﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity.ModelConfiguration;
using System.ComponentModel.DataAnnotations;
using Comswing.Business.Entities;

namespace Comswing.Data.Configuration
{
    internal class UserSwingConfiguration : EntityTypeConfiguration<UserSwing>
    {
        public UserSwingConfiguration()
        {
            HasKey(e => e.Id);

            Property(e => e.Id)
                .IsRequired()
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
                .HasColumnName("Id");

            HasRequired(e => e.User)
                .WithMany(r => r.UserSwings)
                .HasForeignKey(e => e.UserId);

            HasRequired(e => e.Swing)
                .WithMany(r => r.UserSwings)
                .HasForeignKey(e => e.SwingId);

            ToTable("UserSwing","dbo");
        }
    }
}
